# Author: Lovy
# File : loginPage
# Time : 2023-03-17 19:21
from common.basePage import BasePage
from configs.allelements import Locators
from pageObjects.mainPage import MainPage


class LoginPage(BasePage):
    def open_loginpage(self, url):
        self.open_url(url)
        return self

    def login_polly_old(self, username, password):
        import warnings
        warnings.warn("elements 重新定义，要更新方法", DeprecationWarning, stacklevel=2)
        self.input_text(Locators.USERNAME_INPUT_LOCATOR, username)
        self.input_text(Locators.PASSWORD_INPUT_LOCATOR, password)
        self.click_element(Locators.LOGIN_BUTTON_LOCATOR)
        # 登录 成功返回首页对象 PO 第四原则：方法返回其他页面对象，进行页面关联
        return MainPage()

    def login_polly(self, username, password):
        self.input_text(self.username_input, username)
        self.input_text(self.password_input, password)
        self.click_element(self.login_button)
        # 登录 成功返回首页对象 PO 第四原则：方法返回其他页面对象，进行页面关联
        return MainPage()
